package com.copa.l1491;

import java.util.Arrays;

/**
 * @author copa
 * @createDate 2022-08-25 15:28
 * @function 排序法
 */
public class Test2 {

    public double average(int[] salary) {
        Arrays.sort(salary);
        double result = 0;
        for (int i = 1; i < salary.length - 1; i++) {
            result += salary[i];
        }
        return result / (salary.length - 2);
    }

    public static void main(String[] args) {
        int[] salary = {4000,3000,1000,2000};
        System.out.println(new Test2().average(salary));
    }
}
